<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active:hover{
            cursor: pointer;
            color: #0c64eb;
        }
        div{
            display: flex;
            width: 200px;
            justify-content: space-between;
        }
    </style>
</head>

<body>
    <div>
        <h2></h2>
        <h2></h2>
    </div>
</body>
<script>
    let h = document.querySelectorAll('h2');
    let h2 = document.querySelectorAll('h2')[0];
    let h3 = document.querySelectorAll('h2')[1];
    h2.innerText=3;
    h3.innerText=0;
    for(let i=0;i<h.length;i++){
        h[i].addEventListener("mouseenter",function(){
            if(+(h[i].innerText)){
                h[i].className = 'active';
            }
        })
    }
    h2.addEventListener("click",function(){
        if(h2.innerText!=='0'){
            h2.innerText = (+h2.innerText)-1;
            if(h2.innerText==='0'){
            h2.className = '';
            }
        }else if(h2.innerText==='0'){
            h2.innerText = (+h2.innerText)+1;
            if(h2.innerText!=='0'){
            h2.className = 'active';
            }
        }
    })
</script>

</html>